package com.wu.orderadd.service.impl;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.wu.beans.Oreders;
import com.wu.orderadd.dao.OrederDao;
import com.wu.orderadd.service.OrederService;
import com.wu.vo.Reultvo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Date;
import java.util.UUID;

@Service
public class OrederServiceImpl implements OrederService {

    @Autowired
    private OrederDao orederDao;

    @Override
    public Reultvo save(Oreders oreders) {
        //制造熔断机会
//        for (int i = 0; i < 1000000000; i++) {
//            i=0;
//        }

        String orderId = UUID.randomUUID().toString().replace("-", "");
       oreders.setOrederId(orderId);
       oreders.setCreateTime(new Date());
//       oreders.setUserId();
//       oreders.setStatus();
//       oreders.setOrederPrice();
        int i = orederDao.insertOrder(oreders);
        System.out.println("对象为="+oreders);
        System.out.println(i+"==================================");
        if (i>0){
            return Reultvo.success(orderId);
        }else {
            return Reultvo.fail(i,"cuowy");
        }

    }





}
